package br.com.minhascontas.activity;

import java.util.ArrayList;
import java.util.List;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import br.com.minhascontas.activity.grupo.CadastraGrupo;
import br.com.minhascontas.activity.grupo.CadastroItemGrupo;
import br.com.minhascontas.activity.grupo.ExibirGrupos;
import br.com.minhascontas.activity.grupo.ExibirItens;
import br.com.minhascontas.listview.ListViewMenuRelatorio;
import br.com.minhascontas.model.MenuListView;

public class MenuGruposActivity extends ListActivity{
	
	protected void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		
		carregaLista();
	}
	
	private void carregaLista() {

		List<MenuListView> clsMenuList = new ArrayList<MenuListView>();
		MenuListView clsMenu = new MenuListView();
		
		
		String[] values = new String[] { "Novo Grupo", "Exibir/Editar Grupos",
				"Novo Item", "Exibir/Editar Itens" };
		
		for(int i=0;i<values.length; i++ ){
			
			clsMenu = new MenuListView();
			
			clsMenu.setStrNome(values[i]);
			clsMenuList.add(clsMenu);
			
		}
		
		setListAdapter(new ListViewMenuRelatorio(this, clsMenuList));
		
		getListView().setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> adapter, View view, int position,
					long id) {

				Intent intent = new Intent();

				switch (position) {
				case 0:
					intent = new Intent(MenuGruposActivity.this, CadastraGrupo.class);
					break;
				case 1:
					intent = new Intent(MenuGruposActivity.this, ExibirGrupos.class);
					break;
				case 2:
					intent = new Intent(MenuGruposActivity.this,
							CadastroItemGrupo.class);
					break;
				case 3:
					intent = new Intent(MenuGruposActivity.this, ExibirItens.class);
					break;
				}

				startActivity(intent);
			}
		});
	}

}
